错误收集
npm publish 的 github actions
首次脚本:
name: Npm Publish
env:
NODE_VERSION: "16"
on:
push:
tage:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{env.NODE_VERSION}}
registry-url: 'https://registry.npmjs.org'
- name: npm install
run: npm install
- name: Publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{secrets.NPM_TOKEN}}
access: "public"
- name: Release This Version
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.TOKEN }}
无论npm的publish使用第三方action还是自己的命令,npm官网都更新成功,但是命令貌似会被重复执行,导致最后提示包的版本重复
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@mucpsing%2fcli - You cannot publish over the previously published versions: 1.4.3.
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-05-02T15_44_13_267Z-debug-0.log
npm ERR! code 1
npm ERR! path /home/runner/work/cps-cli/cps-cli
npm ERR! command failed
npm ERR! command sh -c npm publish --access public
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-05-02T15_44_12_011Z-debug-0.log
Error: Process completed with exit code 1.
后来发现自己的 package.json 的 scripts 里面存在一个 "publish"命令,命令内容是
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"publish": "npm publish --access public" // 将它删除后,包发布就不再提示重复版本错误了,原因不明
},
}